-
Notifications
You must be signed in to change notification settings - Fork 603
✨ Specific error message for branch protection permission failure. #4892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4892 +/- ##
==========================================
+ Coverage 66.80% 69.69% +2.89%
==========================================
Files 230 251 +21
Lines 16602 15651 -951
==========================================
- Hits 11091 10908 -183
+ Misses 4808 3869 -939
- Partials 703 874 +171 🚀 New features to boost your workflow:
|
clients/githubrepo/branches.go
Outdated
| queryData := new(branchData) | ||
| if err := handler.graphClient.Query(handler.ctx, queryData, vars); err != nil { | ||
| if strings.Contains(err.Error(), "resource not accessible by integration") { | ||
| return nil, sce.WithMessage(sce.ErrScorecardInternal, "Branch protection check failed. Need to use a PAT.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message doesn't convey that the token doesn't have permissions. Would be great to make that clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AdamKorcz Have made the message more clear.
Signed-off-by: kash2104 <kparikh1104@gmail.com>
|
@AdamKorcz Any more changes required? Would appreciate another review. |
|
@spencerschrock Would appreciate a review. |
| // only report permission errors if no ruleset data | ||
| if len(handler.ruleSets) == 0 { | ||
| return nil, sce.WithMessage(sce.ErrScorecardInternal, classicBranchErrMsg) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
This pull request has been marked stale because it has been open for 10 days with no activity |
What kind of change does this PR introduce?
This PR introduces a code change to provide specific error message when branch protection rule fails due to the use of
default GITHUB_TOKENwhich doesn't have permission to view branch protection rules.(Is it a bug fix, feature, docs update, something else?)
feature
What is the current behavior?
When the CI fails because of branch protection rules, it shows generic error message which doesn't give the users an idea of what the actual underlying issue is.
What is the new behavior (if this is a feature change)?**
When error is shown, string matching is done based on which it shows error message specific to the failure of branch protection CI test.
Which issue(s) this PR fixes
Fixes #2946
Special notes for your reviewer
Here
strings.Contains()is case-sensitive so need to adjust the substring or the error message string accordingly.Does this PR introduce a user-facing change?
Yes
For user-facing changes, please add a concise, human-readable release note to
the
release-note(In particular, describe what changes users might need to make in their
application as a result of this pull request.)